<?php

class admin_Form_Administrador extends Zend_Form {

    public function init() 
    {

        $this->setMethod('post');

        $nombre = $this->createElement('text', 'nombre');
        $nombre->addFilters(array('StringTrim'))
                ->addValidators(array('Alnum', array('StringLength', false, array(3, 32))))
                ->setRequired(true)
                ->setLabel('Nombre');

        $apellido = $this->createElement('text', 'apellido');
        $apellido->addFilters(array('StringTrim'))
                ->addValidators(array('Alnum', array('StringLength', false, array(3, 32))))
                ->setRequired(true)
                ->setLabel('Apellido');


        $correo = $this->createElement('text', 'correo');
        $correo->addFilters(array('StringTrim', 'StringToLower'))
                ->addValidator('EmailAddress', true)
                ->setRequired(true)
                ->setLabel('Correo');


        $clave = $this->createElement('password', 'clave');
        $clave->addFilters(array('StringTrim', 'StringToLower'))
                ->addValidators(array('Alnum', array('StringLength', false, array(4, 8))))
                ->setRequired(true)
                ->setLabel('Clave');

        $nivel = $this->createElement('select', 'nivel');
        $nivel->setLabel('Nivel')
                ->addMultiOptions(array(
                    'colaborador' => 'Colaborador',
                    'editor' => 'Editor',
                    'super' => 'Super',
                ));

        $crear = $this->createElement('submit', 'crear');
        $crear->setRequired(false)
                ->setIgnore(true)
                ->setLabel('Guardar')
                ->setAttrib('class', 'button')
                ->removeDecorator('DtDdWrapper');

        $reestablecer = $this->createElement('reset', 'reset');
        $reestablecer->setRequired(false)
                ->setIgnore(true)
                ->setLabel('Reestablecer')
                ->setAttrib('class', 'button')
                ->removeDecorator('DtDdWrapper');

        $this->addElements(array($nombre, $apellido, $correo, $clave, $nivel, $crear, $reestablecer));
    }

}

